console.log('-------------------------------------------------------------------------------');
const m = new WeakMap();
console.log(m);//WeakMap { <items unknown> }
const key1 = {id:'1'};
const key2 = {id:'2'};
const key3 = {id:'3'};
const m1 = new WeakMap([[key1,'value1'],[key2,'value2'],[key3,'value3']]);
console.log(m1.get(key1));//value1
console.log(m1.get(key2));//value2

// const m2 = new WeakMap([[key1,'value1'],['key2','value2'],[key3,'value3']]);
// console.log(m2);//TypeError: Invalid value used as weak map key
console.log('----------------------------------------------------------------');
const stringKey = new String("key1"); 
const wm3 = new WeakMap([[ 
    stringKey, "val1" 
   ]]);
console.log(wm3.get(stringKey));//val1
console.log("----------------------------------------------------------------------");
const m4 = new WeakMap();
const key4 = {id:'1'};
const key5 = {id:'2'};
console.log(m4.get(key4));//undefined
console.log(m4.has(key5));//false
m4.set(key4,"value4")
  .set(key5,"value5");
console.log(m4.get(key4));//value4
console.log(m4.has(key5));//true
m4.delete(key4);
console.log(m4.get(key4));//undefined
console.log('--------------------------------------------------------------------------');
const str = 'haha';
const m6 = new Map().set(str,'value1');
console.log(m6.get(str));//value1
console.log(m6.get('haha'));//value1